-
Notifications
You must be signed in to change notification settings - Fork 0
Hw14 #5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Кажется у тебя есть гит-репозиторий внутри гит-репозитория
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Раз файл пустой можно удалить:)
| from Bio import SeqIO | ||
| from Bio.SeqUtils import GC | ||
|
|
||
| def filter_fastq(input_path: str, quality_threshold: int, output_filename="final_filtered.fastq", gc_bounds=(40, 60), length_bounds=(50, 350)): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Тут не хватает докстринги (тем более же что по идее увас они были в прошлом семестре
| ###GC content filter | ||
| min_gc_content = gc_bounds[0] | ||
| max_gc_content = gc_bounds[1] | ||
| GC_quality_filt = [] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Переменные только с маленькими буквами!
| result_quality = SeqIO.write(GC_quality_filt, "good_quality_GC.fastq", "fastq") | ||
| result_quality_GC_length = SeqIO.parse("good_quality_GC.fastq", "fastq") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
С точки зрения использования функционала биопитона - все супер. Но как код организован - не очень хорошо к сожалению. У тебя получается как-то разбросаны проверки, при чем после каждой проверке ты создаешь новый файл на компьютере куда записываешь сиквенсы. Ну и между этими промежутками чтения и записи все файлы ты держишь в памяти. В этом плане все можно было бы организовать гораздо проще и еще и лучше.
Сперва мы открываем файл на запись. После этого мы в цикле for читаем записи из входного файла. На каждой итерации цикла мы держим в памяти одну запись, мы проверяем ее всеми нужными проверками и если все ок - то записыаем в файл. При этом никаких промежуточных файлов в большом количестве не создается.
Псведокод:
with open(output) as outf:
for seq in SeqIO.parse(input):
if ok and ok and ok:
SeqIO.write(seq, outf)| list_input = list(self.seq) | ||
| for i in range(len(self.seq)): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
не надо итерироваться по индексам и потом брать [i] если можно сразу делать цикл по буквам
| for i in range(len(self.seq)): | ||
| if list_input[i] in self.complement_dict: | ||
| list_input[i] = self.complement_dict[list_input[i]] | ||
| return "".join(list_input) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
У тебя получается была ДНК, а после complement стала просто строка. Чтобы тип данных оставался как есть можно сделать:
| return "".join(list_input) | |
| return type(self)("".join(list_input)) |
Если не понимаешь что тут - можем на консультации еще обсудить
| complement_dict = {'A': 'T', 'T': 'A', 'G': 'C', 'C': 'G', 'a': 't', 't': 'a', 'g': 'c', 'c': 'g'} | ||
| def __init__(self, seq): | ||
| super().__init__(seq) | ||
| #self.complement() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| #self.complement() |
| def __init__(self, seq): | ||
| super().__init__(seq) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
в целом это можно не писать, так как по дефолту инит родителя и будет работать
| if list_input[i] in self.complement_dict: | ||
| list_input[i] = self.complement_dict[list_input[i]] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
А что если else? Кажется такого быть не может, если при инициализации происходит поверка что все буквы валидны
FASTQ filter function using biopython and task 5